{extend name="template/base" /}
{block name="content"}
<div class="page-container">
    <form class="mb-20" method="get" action="{:\\think\\Url::build($Request.action)}">
        <input type="text" class="input-text" style="width:250px" placeholder="标题" name="title" value="{$Request.param.title}">
        <div class="select-box" style="width:250px">
            <select name="dispatch_group_status" class="select">
                <option value="">选择状态</option>
                {volist name=":config('dispatch_group_status')" id="group_status"}
                <option value="{$key}">{$group_status}</option>
                {/volist}
            </select>
        </div>
        <div class="select-box" style="width:250px">
            <select name="car_form" class="select"  id="car_form">
                <option value="">选择用车形式</option>
                <option value="拼车" {eq name="Request.param.car_form" value="拼车"} selected = "selected" {/eq} >拼车</option>
                <option value="包车"  {eq name="Request.param.car_form" value="包车"} selected = "selected" {/eq}>包车</option>
                <option value="定制"  {eq name="Request.param.car_form" value="定制"} selected = "selected" {/eq}>定制</option>
                <option value="深度游"  {eq name="Request.param.car_form" value="深度游"} selected = "selected" {/eq}>深度游</option>
            </select>
        </div>
        <input type="text" class="input-text" style="width:250px" placeholder="结算方式" name="settlement_mode" value="{$Request.param.settlement_mode}">

        <button type="submit" class="btn btn-success" id="realname_btn" name=""><i class="Hui-iconfont">&#xe665;</i> 搜索</button>
    </form>


    <div class="cl pd-5 bg-1 bk-gray">
        <span class="l">
            {tp:menu menu="add" /}
        </span>
        <span class="r pt-5 pr-5">
            共有数据 ：<strong>{$count ?? '0'}</strong> 条
        </span>
    </div>
    <table class="table table-border table-bordered table-hover table-bg mt-20">
        <thead>
        <tr class="text-c">
            <th width="25"><input type="checkbox"></th>
            <th width="">id</th>
            <th width="">标题</th>
            <th width="">数量</th>
            <th width="">状态</th>
            <th width="">拒接时间</th>
            <th width="">拒接理由</th>
            <th width="">司机</th>
            <th width="">用车形式</th>
            <th width="">出发日期</th>
            <th width="">结束日期</th>
            <th width="70">操作</th>
        </tr>
        </thead>
        <tbody>
        {volist name="list" id="vo"}
        <tr class="text-c">

            <td><input type="checkbox" name="id[]" value="{$vo.id}"></td>
            <td>{$vo.id}</td>
            <td>{$vo.title}</td>
            <td>{$vo.num}</td>
            <td>{:config('dispatch_group_status')[$vo.dispatch_group_status]}</td>
            <td>{:date('Y-m-d H:i:s',$vo.reject_time)}</td>
            <td>{$vo.reject_reason}</td>
            <td>{$vo.driver_user_id}:{$vo.realname}</td>
            <td>{$vo.car_form}</td>
            <td>{:date('Y-m-d H:i:s',$vo.go_date)}</td>
            <td>{:date('Y-m-d H:i:s',$vo.end_date)}</td>

            <td class="f-14">
                {eq name="vo.isreject" value="1"}
                    <a href="javascript:;" onclick="reset_group('/admin/dispatch_traveler_group/reset_group/group_id/{$vo.id}')" class="label label-warning radius" title="重置状态">重置状态</a>
                    {tp:menu menu='sedit' /}
                {else/}
                    {switch name="vo.dispatch_group_status"}
                    {case value="sendorders"}
                            <a href="javascript:;" onclick="accept('/admin/dispatch_traveler_group/accept/group_id/{$vo.id}')" class="label label-warning radius" title="司机接受">司机接受</a>
                            <a href="javascript:;" onclick="reset_group('/admin/dispatch_traveler_group/reset_group/group_id/{$vo.id}')" class="label label-warning radius" title="取消司机">取消司机</a>
                            {php}
                            $exceptional_order=get_exceptional_order($vo['id']);
                            {/php}
                            {if condition="$exceptional_order"}
                            <a title="编辑选项" href="javascript:;" onclick="layer_open('编辑选项','/admin/dispatch_traveler_group/exceptional/group_id/{$vo.id}')" style="text-decoration:none" class="ml-5 label label-warning radius">异常信息</a>
                            {/if}
                            {tp:menu menu='sedit' /}
                    {/case}
                    {case value="proceed"}
                            <a href="javascript:;" onclick="accomplish('/admin/dispatch_traveler_group/accomplish/id/{$vo.id}')" class="label label-warning radius" title="司机已完成">司机已完成</a>
                            <a href="javascript:;" onclick="reset_group('/admin/dispatch_traveler_group/reset_group/group_id/{$vo.id}')" class="label label-warning radius" title="取消司机">取消司机</a>
                            {php}
                            $exceptional_order=get_exceptional_order($vo['id']);
                            {/php}
                            {if condition="$exceptional_order"}
                            <a title="编辑选项" href="javascript:;" onclick="layer_open('编辑选项','/admin/dispatch_traveler_group/exceptional/group_id/{$vo.id}')" style="text-decoration:none" class="ml-5 label label-warning radius">异常信息</a>
                            {/if}
                    {/case}
                    {case value="achieve"}
                            <a href="javascript:;" onclick="settlement('/admin/dispatch_traveler_group/settlement/group_id/{$vo.id}')" class="label label-warning radius" title="结算">结算</a>
                            <a href="javascript:;" onclick="reset_group('/admin/dispatch_traveler_group/reset_group/group_id/{$vo.id}')" class="label label-warning radius" title="取消司机">取消司机</a>
                            <a href="javascript:;" onclick="reject_settlement('/admin/dispatch_traveler_group/reject_settlement/group_id/{$vo.id}')" class="label label-warning radius" title="结算不通过">结算不通过</a>
                            {php}
                            $exceptional_order=get_exceptional_order($vo['id']);
                            {/php}
                            {if condition="$exceptional_order"}
                            <a title="编辑选项" href="javascript:;" onclick="layer_open('编辑选项','/admin/dispatch_traveler_group/exceptional/group_id/{$vo.id}')" style="text-decoration:none" class="ml-5 label label-warning radius">异常信息</a>
                            {/if}
                            {tp:menu menu='sedit' /}
                    {/case}
                    {case value="accounts"}
                            {tp:menu menu='sedit' /}
                    {/case}
                    {default /}
                            <a title="分配司机" href="javascript:;" onclick="layer_open('分配司机','/admin/dispatch_traveler_group/send_driver/group_id/{$vo.id}')" style="text-decoration:none" class="label label-warning radius">分配司机</a>
                            {php}
                            $exceptional_order=get_exceptional_order($vo['id']);
                            {/php}
                            {if condition="$exceptional_order"}
                            <a title="编辑选项" href="javascript:;" onclick="layer_open('编辑选项','/admin/dispatch_traveler_group/exceptional/group_id/{$vo.id}')" style="text-decoration:none" class="ml-5 label label-warning radius">异常信息</a>
                            {/if}
                           {tp:menu menu='sedit' /}
                    {/switch}
                {/eq}
            </td>
        </tr>
        {/volist}
        </tbody>
    </table>
    <div class="page-bootstrap">{$page ?? ''}</div>
</div>
{/block}

{block name="script"}
<script type="text/javascript" src="__LIB__/My97DatePicker/WdatePicker.js"></script>

<script>
    // function send_driver(url) {
    //     $.ajax({
    //         type: 'POST',
    //         url: url,
    //         data: null,
    //         success: function (re){
    //             layer.msg(re.msg, {
    //                 time: 2000, //2s后自动关闭
    //             },function () {
    //                 //关闭后刷新
    //                 location.reload();
    //             });
    //         },
    //     });
    // }
    function reset_group(url) {
        $.ajax({
            type: 'POST',
            url: url,
            data: null,
            success: function (re){
                if(re.msg) {
                    layer.msg(re.msg, {
                        time: 2000, //2s后自动关闭
                    }, function () {
                        //关闭后刷新
                        location.reload();
                    });
                }else{
                    layer_open('取消司机','/admin/pub/role/id/1')
                }
            },
        });
    }
    function settlement(url) {
        $.ajax({
            type: 'POST',
            url: url,
            data: null,
            success: function (re){
                if(re.msg) {
                    layer.msg(re.msg, {
                        time: 2000, //2s后自动关闭
                    }, function () {
                        //关闭后刷新
                        location.reload();
                    });
                }else{
                    layer_open('结算','/admin/pub/role/id/1')
                }
            },
        });
    }
    function reject_settlement(url) {
        $.ajax({
            type: 'POST',
            url: url,
            data: null,
            success: function (re){
                if(re.msg) {
                    layer.msg(re.msg, {
                        time: 2000, //2s后自动关闭
                    }, function () {
                        //关闭后刷新
                        location.reload();
                    });
                }else{
                    layer_open('结算不通过','/admin/pub/role/id/1')
                }
            },
        });
    }
    $(function () {
        $("[name='dispatch_group_status']").find("[value='{$Request.param.dispatch_group_status}']").attr("selected", true);
        $("[name='car_form']").find("[value='{$Request.param.car_form}']").attr("selected", true);
    })
</script>
{/block}